﻿using banyuetan_2_0.Common.Enum;
using SqlSugar;
using System;
using System.Collections.Generic;

namespace banyuetan_2_0.Model.Models
{
    /// <summary>
    /// 文章表
    /// </summary>
    public class Article
    {   
        /// <summary>
        /// id
        /// </summary>
        [SugarColumn(IsPrimaryKey =true,IsNullable =false,IsIdentity =true)]
        public int aId { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        [SugarColumn(ColumnDataType ="nvarchar",Length =50,IsNullable =false)]
        public string aTitle { get; set; }
        /// <summary>
        /// 简介
        /// </summary>
        [SugarColumn(ColumnDataType ="nvarchar",Length =200,IsNullable =true)]
        public string aDescribe { get; set; }
        /// <summary>
        /// 正文
        /// </summary>
        [SugarColumn(ColumnDataType ="text",IsNullable =false)]
        public string aContent { get; set; }
        /// <summary>
        /// 封面大图id
        /// </summary>
        [SugarColumn(IsNullable =true)]
        public int aTitlePicId { get; set; }
        /// <summary>
        /// 封面大图导航属性
        /// </summary>
        [Navigat(NavigatType.ManyToOne,nameof(aTitlePicId))]
        public Source aTitlePic { get; set; }
        /// <summary>
        /// 文章状态，默认为待审核状态
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public Status aStatus { get; set; } = Status.PendingReview;
        /// <summary>
        /// 文章权重，默认为0
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public double aWeight { get; set; } = 0;
        /// <summary>
        /// 更新时间，默认为当前时间
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public DateTime aUpdateTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 是否删除，默认为否
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public bool aIsDeleted { get; set; } = false;
        /// <summary>
        /// 访问量统计
        /// </summary>
        [SugarColumn(IsNullable =false)]
        public int aVisitCount { get; set; } = 0;
        /// <summary>
        /// 作者Id
        /// </summary>
        [SugarColumn(IsNullable =true)]
        public int aEditorId { get; set; }
        /// <summary>
        /// 导航属性：作者
        /// </summary>
        [Navigat(NavigatType.ManyToOne,nameof(aEditorId))]
        public sysUserInfo aEditor { get; set; }

        //2022年10月26日19:53:43新加属性
        /// <summary>
        /// 作者
        /// </summary>
        [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
        public string aAuthorName { get; set; } = "";
        /// <summary>
        /// 来源
        /// </summary>
        [SugarColumn(ColumnDataType = "nvarchar", Length = 50, IsNullable = true)]
        public string aComeFrom { get; set; } = "";
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime aCreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// Source集合导航属性
        /// </summary>
        [Navigat(typeof(ArticleAndSource),nameof(ArticleAndSource.aId),nameof(ArticleAndSource.sId))]
        public List<Source> Sources { get; set; }
    }
}
